<?php


namespace app\cms\aspect;


use app\cms\home\index;
use app\cms\model\siteModel;
use iflow\aop\Abstracts\AbstractAspect;
use iflow\aop\Annotation\Aspect;
use iflow\Response;

#[Aspect([
    index::class
])]
class siteHomeStatus extends AbstractAspect
{
    public function process(\Closure $closure, array $args = []): Response
    {
        // TODO: Implement process() method.
        $config = siteModel::getSiteInfo() -> data;
        if ($config['code'] !== 200) {
            return message() -> nodata('请先配置站点信息');
        }
        if (intval($config['items']['status']) === 0) return response() -> data("站点已关闭，如有问题请联系站点管理员");
        return $closure(...$args);
    }
}